home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb / sprite / RCS / keymaps.c,v < prev    next >
Encoding:
Text File  |  1990-12-10  |  4.3 KB  |  216 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     90.12.09.22.36.06;  author rab;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     90.11.12.19.03.14;  author rab;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @Changes for Sprite. (Mike checking in for Bob.)
  27. @
  28. text
  29. @/* keymaps.c -- Functions and keymaps for the GNU Readline library. */
  30.  
  31. /* Copyright (C) 1988,1989 Free Software Foundation, Inc.
  32.  
  33.    This file is part of GNU Readline, a library for reading lines
  34.    of text with interactive input and history editing.
  35.  
  36.    Readline is free software; you can redistribute it and/or modify it
  37.    under the terms of the GNU General Public License as published by the
  38.    Free Software Foundation; either version 1, or (at your option) any
  39.    later version.
  40.  
  41.    Readline is distributed in the hope that it will be useful, but
  42.    WITHOUT ANY WARRANTY; without even the implied warranty of
  43.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  44.    General Public License for more details.
  45.  
  46.    You should have received a copy of the GNU General Public License
  47.    along with Readline; see the file COPYING.  If not, write to the Free
  48.    Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  49.  
  50. #include "keymaps.h"
  51. #include "emacs_keymap.c.h"
  52.  
  53. #ifdef VI_MODE
  54. #include "vi_keymap.c.h"
  55. #endif
  56.  
  57. /* Remove these declarations when we have a complete libgnu.a. */
  58. #define STATIC_MALLOC
  59. #ifndef STATIC_MALLOC
  60. extern char *xmalloc (), *xrealloc ();
  61. #else
  62. static char *xmalloc (), *xrealloc ();
  63. #endif
  64.  
  65. /* **************************************************************** */
  66. /*                                    */
  67. /*              Functions for manipulating Keymaps.        */
  68. /*                                    */
  69. /* **************************************************************** */
  70.  
  71.  
  72. /* Return a new, empty keymap.
  73.    Free it with free() when you are done. */
  74. Keymap
  75. rl_make_bare_keymap ()
  76. {
  77.   register int i;
  78.   Keymap keymap = (Keymap)xmalloc (128 * sizeof (KEYMAP_ENTRY));
  79.  
  80.   for (i = 0; i < 128; i++)
  81.     {
  82.       keymap[i].type = ISFUNC;
  83.       keymap[i].function = (Function *)NULL;
  84.     }
  85.  
  86.   for (i = 'A'; i < ('Z' + 1); i++)
  87.     {
  88.       keymap[i].type = ISFUNC;
  89.       keymap[i].function = rl_do_lowercase_version;
  90.     }
  91.  
  92.   return (keymap);
  93. }
  94.  
  95. /* Return a new keymap which is a copy of MAP. */
  96. Keymap
  97. rl_copy_keymap (map)
  98.      Keymap map;
  99. {
  100.   register int i;
  101.   Keymap temp = rl_make_bare_keymap ();
  102.  
  103.   for (i = 0; i < 128; i++)
  104.     {
  105.       temp[i].type = map[i].type;
  106.       temp[i].function = map[i].function;
  107.     }
  108.   return (temp);
  109. }
  110.  
  111. /* Return a new keymap with the printing characters bound to rl_insert,
  112.    the uppercase Meta characters bound to run their lowercase equivalents,
  113.    and the Meta digits bound to produce numeric arguments. */
  114. Keymap
  115. rl_make_keymap ()
  116. {
  117.   extern rl_insert (), rl_rubout (), rl_do_lowercase_version ();
  118.   extern rl_digit_argument ();
  119.   register int i;
  120.   Keymap newmap;
  121.  
  122.   newmap = rl_make_bare_keymap ();
  123.  
  124.   /* All printing characters are self-inserting. */
  125.   for (i = ' '; i < 126; i++)
  126.     newmap[i].function = rl_insert;
  127.  
  128.   newmap[TAB].function = rl_insert;
  129.   newmap[RUBOUT].function = rl_rubout;
  130.  
  131.   return (newmap);
  132. }
  133.  
  134. /* Free the storage associated with MAP. */
  135. rl_discard_keymap (map)
  136.      Keymap (map);
  137. {
  138.   int i;
  139.  
  140.   if (!map)
  141.     return;
  142.  
  143.   for (i = 0; i < 128; i++)
  144.     {
  145.       switch (map[i].type)
  146.     {
  147.     case ISFUNC:
  148.       break;
  149.  
  150.     case ISKMAP:
  151.       rl_discard_keymap ((Keymap)map[i].function);
  152.       break;
  153.  
  154.     case ISMACR:
  155.       free ((char *)map[i].function);
  156.       break;
  157.     }
  158.     }
  159. }
  160.  
  161. #ifdef STATIC_MALLOC
  162.  
  163. /* **************************************************************** */
  164. /*                                    */
  165. /*            xmalloc and xrealloc ()                     */
  166. /*                                    */
  167. /* **************************************************************** */
  168.  
  169. static char *
  170. xmalloc (bytes)
  171.      int bytes;
  172. {
  173.   static memory_error_and_abort ();
  174.   char *temp = (char *)malloc (bytes);
  175.  
  176.   if (!temp)
  177.     memory_error_and_abort ();
  178.   return (temp);
  179. }
  180.  
  181. static char *
  182. xrealloc (pointer, bytes)
  183.      char *pointer;
  184.      int bytes;
  185. {
  186.   static memory_error_and_abort ();
  187.   char *temp = (char *)realloc (pointer, bytes);
  188.  
  189.   if (!temp)
  190.     memory_error_and_abort ();
  191.   return (temp);
  192. }
  193.  
  194. static
  195. memory_error_and_abort ()
  196. {
  197.   fprintf (stderr, "readline: Out of virtual memory!\n");
  198.   abort ();
  199. }
  200. #endif /* STATIC_MALLOC */
  201. @
  202.  
  203.  
  204. 1.1
  205. log
  206. @Initial revision
  207. @
  208. text
  209. @d23 1
  210. a23 1
  211. #include "emacs_keymap.c"
  212. d26 1
  213. a26 1
  214. #include "vi_keymap.c"
  215. @
  216.